# -*- coding: UTF-8 -*-
'''
Created on 09/10/2014

@author: Eduardo Cardeira - Num 6033

Exemplo 2 da Aula Teorica 3

'''
def fatorial(n):
    if n <= 0:
        return 1
    else:
        return n * fatorial(n-1)
    pass

def fatorial_cauda(n):
    def fact(i = n, acc = 1):
        if i == 0:
            return acc
        else:
            return fact(i-1, (acc * i))
    return fact()

print fatorial_cauda(5)